package com.main.tcp;

import com.exception.ModbusException;

import java.io.IOException;

public class Test {

    public static void main(String[] args) throws IOException, ModbusException {
//        ModbusTcpClient client = ModbusClientFactory.createModbusMasterTCP("127.0.0.1", 502);
//        client.connect();
//        JsonResult jr = client.readCoils(0, 10);
//        for (ResponseData value : jr.getData()) {
//            System.out.println(value.getValue());
//        }
//
//        boolean[] values = client.readDiscreteInputs(0, 10);
//        for (boolean value : values) {
//            System.out.println(value);
//        }
//        JsonResult jr = client.readHoldingRegisters(0, 10);
//        for (ResponseData data : jr.getData()) {
//            System.out.println(data.getAddress() + " : " + data.getValue());
//        }
//        JsonResult jr = client.readInputRegisters(0, 10);
//        for (ResponseData data : jr.getData()) {
//            System.out.println(data.getAddress() + " : " + data.getValue());
//        }
//        JsonResult jr = client.writeCoil(3, true);
//          JsonResult jr = client.writeHoldingRegister(5, 102);
//        JsonResult jr = client.multipleWriteCoils(2,new boolean[] {true, false, true, false});
//        JsonResult jr = client.multipleWriteHoldingRegisters(3, new int[]{1,0,0,5,7});
    }
}
